<html>
<head>
    <script src="/js/validate.js" type="text/javascript"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body style="background-color: transparent">
<form id="id-form" name="frm" method="post" action="/globalconfig/dealcategory/save" enctype="multipart/form-data">
    <div id="toolbar-button">
			<div class="item" onclick="save()" name="SAVE" id="itemButton2" title="Lưu">
				<div id="save-global-button"></div>
			</div>
			<div class="item" onclick="back()" id="itemButton3" title="Trở lại">
				<div id="back-global-button"></div>				
			</div>
	</div>
	<input type="hidden" name="id" value="<?= $this->data['DEALCATEGORYID']; ?>" />
	<table >
         <tr>
        	<td>
        	Tên loại sản phẩm <font color="red">* </font> 
        	</td>
        	<td>
        	<input class="inp-form" id="idName" name="name" value="<?=$this->data['NAME']; ?>" type="text"  size="30"/>
        	</td>
            <td nowrap="nowrap"></td>
        	<td>        	
        	</td>
        </tr>
        
		<tr>  	
        	<td nowrap="nowrap">Loại sản phẩm cha</td>        	
			
			<!--Start of combobox-->
			<td>                    
				<select style="width: 200px; height:30px" name="parentid" value="">
					<option value="">-- Chọn loại sản phẩm cha --</option>
					<?php 
						$this->dataSource1 = $this->dataSource;
						foreach($this->dataSource as $item){
							//if($item['PARENTID']==0){
								$level = 0;
								$spaceLevel = "__";
								echo '<option  value="'.$item['DEALCATEGORYID'].'" ';
								if($item['DEALCATEGORYID'] == $this->data['PARENTID'])
									echo 'selected';
								else 
									echo '';
								echo '><b>'.$item['NAME'].'</b></option>';
								//while(count($this->dataSource1o) > 0){
									// foreach($this->dataSource1 as $item1){
										// if($item1['PARENTID'] == $item['DEALCATEGORYID'])
										// {
											// $level++;
											// for($i=1;$i<$level;$i++)
											// {
												// $spaceLevel = $spaceLevel + $spaceLevel;
											// }	
											// echo '<option value="'.$item1['DEALCATEGORYID'].'"><b>|'.$spaceLevel.$item1['NAME'].'</b></option>';
											// unset($item1['DEALCATEGORYID']);										
										// }
										// else
										// {
											// echo '<option value="'.$item1['DEALCATEGORYID'].'"><b>'.$spaceLevel.$item1['NAME'].'</b></option>';
										// }
									//}
								//}							
							//}
							// else 
								// echo '<option value="'.$item['DEALCATEGORYID'].'"><b>|____'.$item['NAME'].'</b></option>';
						}
					?>
				</select>                   
				<br />               
			<!--End of combobox-->
        	</td> 
		</tr>  
        <tr>  	
        	<td>Kích hoạt</td>
        	<td>
				<input type="checkbox" id='iStatus' value="1" name="status" <?php if ($this->data['STATUS'] == 1) echo "checked";?> />
			</td>			
        </tr>
   	</table>
    
</form>
<Script language="JavaScript">
	
    function save(){
        var flag=0;
    	var name= document.getElementById('idName');
    	if(name == null || name == ''){
        	alert('Tên loại sản phẩm không được trống.');
        	flag=1;
        	return;
        	}else{
        		flag=0;
            	}
    	if(flag==0){
				document.frm.submit();
        	}
    	else{
				return;
        	}            
    }
	
	function back(){
        document.location.href='/globalconfig/dealcategory/index';
    }	
	
</Script>
</body>
</html>